package com.bmt.core;

import java.util.ArrayList;
import java.util.List;

import com.bmt.utils.System_Utils;

public class PageListInfo<T extends ISaveable> {
	private Integer currPageNum;
	private Integer totalPageNum= 0;
	private Integer pageSize=System_Utils.PAGE_SIZE;
	private Integer dataTotalNum=0;
	private List<String> pageList;
	private List<T> dataList;

	public Integer getCurrPageNum() {
		return currPageNum;
	}

	public void setCurrPageNum(Integer currPageNum) {
		this.currPageNum = currPageNum;
	}

	public Integer getTotalPageNum() {
		return totalPageNum;
	}
	
	public static void main(String[] args) {
		System.out.println(18%5);
	}

	public void setTotalPageNum(Integer totalPageNum) {
		this.totalPageNum = totalPageNum;
	}

	public Integer getPageSize() {
		return pageSize;
	}

	public void setPageSize(Integer pageSize) {
		this.pageSize = pageSize;
		doTotalPageNum();
	}

	public Integer getDataTotalNum() {
		return dataTotalNum;
	}

	public void setDataTotalNum(Integer dataTotalNum) {
		this.dataTotalNum = dataTotalNum;
		doTotalPageNum();
	}

	private void doTotalPageNum() {
		int remainder=0;
		if (this.dataTotalNum > 0 && pageSize>0) {
			remainder=this.dataTotalNum % pageSize;
			if(remainder>0){
				totalPageNum = this.dataTotalNum / pageSize + 1;//有余数需要加多一页
			}else {
				totalPageNum = this.dataTotalNum / pageSize;
			}
			
		}
	}

	public List<String> getPageList() {
		if (pageList == null)
			pageList = new ArrayList<String>();
		pageList.clear();
		int totalPageNum=getTotalPageNum();
		if(this.totalPageNum>=1){
			for(int pageNum=1 ; pageNum<= totalPageNum;pageNum++){
				pageList.add(String.valueOf(pageNum));
			}
		}
		
		return pageList;
		
	}

	public List<String> test() {
		if (pageList == null) {
			pageList = new ArrayList<String>();
		}
		pageList.clear();

		return pageList;

	}

	public List<T> getDataList() {
		if (dataList == null)
			dataList = new ArrayList<T>();
		return dataList;
	}

	public void setDataList(List<T> dataList) {
		this.dataList = dataList;
	}

}
